@layout("/common/_container.html"){
<div class="ibox-content">
    <div style="display: none">
        <input type="hidden" id="customerId" value="${customerId}">
        <input type="hidden" id="payservicenameValue" value="">
    </div>
    <div class="clearfix">
        <div class="col-sm-12">
            <ul class="ul_li" style="display: flex">
                <li>
                    <span>医生</span>
                    <input type="text" id="doctor" class="selecteds" value="${doctor}">
                </li>
                <li>
                    <span>就诊时间</span>
                    <input type="text" id="diagnoseTime"  class="selecteds" value="${arrivalTime}">
                </li>
                <li>
                    <span>项目</span>
                    <select id="expenditureProject" name="expenditureProject" class="selecteds"></select>
                </li>
            </ul>
        </div>
        <div class="col-sm-12">
            <div style="display: flex;padding-bottom: 20px;">
                <div style="flex: 1;">
                    <h3>添加就诊详情</h3>
                    <textarea style="height: 100px;width: 95%" id="diagnoseDetail" name="diagnoseDetail"></textarea>
                </div>
                <div style="flex: 1;">
                    <h3>备注</h3>
                    <textarea style="height: 100px;width: 95%" name="remarks" id="remarks"></textarea>
                </div>
            </div>
        </div>
        <div class="btn_box col-sm-12">
            <button type="button" class="btn"  onclick="addDoctorDiagnose()">提交</button>
            <button type="button" class="btn" onclick="cancel()" style="background-color: #999999">取消</button>
        </div>
    </div>
</div>
<script>
    $(function () {
        //初始化下拉消费项目
        $.post(Feng.ctxPath + "/payService/getList", function (data) {
            var txt = '<option value="">--请选择项目--</option>';
            for (var i = 0; i < data.length; i++) {
                txt += '<option value="' + data[i].department + '">' + data[i].department + '</option>';
            }
            document.getElementById('expenditureProject').innerHTML = txt;
            //状态单选
            var seletepayservicename = $('#payservicenameValue').val();
            if (seletepayservicename != "") {
                $("#expenditureProject option[value=" + seletepayservicename + "]").attr("selected", "selected");
            }
        }, "json");
    })
    function cancel() {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
    }

    function addDoctorDiagnose () {
        var customerId = $("#customerId").val();
        var doctor = $("#doctor").val();
        var diagnoseTime = $("#diagnoseTime").val();
        var expenditureProject = $("#expenditureProject").val();
        var diagnoseDetail = $("#diagnoseDetail").val();
        var remarks = $("#remarks").val();

        if ($('#diagnoseDetail').val() == "" || $('#diagnoseDetail').val() == null) {
            alert("就诊详情不能为空");
            return;
        }
        $.ajax({
            url: Feng.ctxPath + "/doctorLooked/add_record",
            type: "post",
            data: {
                "customerId": customerId,
                "doctor": doctor,
                "diagnoseTime": diagnoseTime,
                "expenditureProject": expenditureProject,
                "diagnoseDetail": diagnoseDetail,
                "remarks": remarks,
            },
            success: function (data) {
                Feng.success("添加成功!");
                window.parent.DoctorLooked.table.refresh();
                cancel()
            },
            error: function (data) {
                alert('添加失败!');
            }
        });

    }

</script>
@}
<style>
    .selecteds{ width:60% ; height: 39px;padding-left: 10px;}
    ul{  margin: 0;  padding: 0;  }
    input {  border: 1px solid #a9a9a9;  border-radius: 3px; }
    .ul_li > li { flex: 1; padding: 20px 0; }
    .ul_li span { display: inline-block; width: 90px;  }
    .btn_box button {  margin: 0;  color: white;  background: #2b6594;  padding: 6px 30px;  font-size: 1em;  }
</style>
